package club.monkeywood.repository;

import club.monkeywood.dataobject.Support;
import club.monkeywood.dto.buyer.SupportDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface SellerSupportRepository extends JpaRepository<Support, Integer> {

    @Query(value = "select new club.monkeywood.dto.buyer.SupportDTO(" +
            " b.id, b.description, a.sellerId) " +
            " from SellerSupport a,Support b " +
            " where a.supportId = b.id ")
    List<SupportDTO> queryBySellerId(@Param("sellerId") Integer sellerId);

}
